﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Physis.Core {

    public class CoreDateSegmentObject: CoreObject {

        #region Private Properties 

        private DateTime effectiveDate = DateTime.MinValue;

        private DateTime terminationDate = DateTime.MaxValue;

        private Boolean voided = false;

        #endregion 


        #region Public Properties 

        public DateTime EffectiveDate { get { return effectiveDate; } set { effectiveDate = value; } }

        public DateTime TerminationDate { get { return terminationDate; } set { terminationDate = value; } }

        public Boolean Voided { get { return voided; } set { voided = value; } }

        #endregion 


        #region Constructors

        protected CoreDateSegmentObject () { return; }

        public CoreDateSegmentObject (Application forApplication) : base (forApplication) { return; }

        public CoreDateSegmentObject (Application forApplication, Int64 forId) : base (forApplication, forId) { return; }

        #endregion 
        

        #region Database Functions

        public override void MapDataFields (System.Data.DataRow currentRow) {

            base.MapDataFields (currentRow);


            EffectiveDate = Data.Readers.DataReader.DateTimeFromDatabase (currentRow, "EffectiveDate");

            TerminationDate = Data.Readers.DataReader.DateTimeFromDatabase (currentRow, "TerminationDate");

            Voided = Data.Readers.DataReader.BooleanFromDatabase (currentRow, "Voided");


            return;

        }

        #endregion 


        #region Public Methods

        public Boolean ContainsDate (DateTime compareDate) {

            return ((compareDate >= effectiveDate) && (compareDate <= terminationDate));

        }

        #endregion 

    }

}
